Version

AddHyperlink(String,IList<TextRun>,String) Method

Adds a textual hyperlink to the current paragraph.
Syntax
'Declaration
 
Public Overloads Sub AddHyperlink( _
   ByVal address As String, _
   ByVal textRuns As IList(Of TextRun), _
   ByVal toolTipText As String _
) 
public void AddHyperlink( 
   string address,
   IList<TextRun> textRuns,
   string toolTipText
)

Parameters

address
The address for the hyperlink.
textRuns
A list of TextRun instances which define the rich content for the hyperlink.
toolTipText
The text that is displayed when the user hovers the cursor over this hyperlink.
Exceptions
ExceptionDescription
WordDocumentWriterExceptionThrown if no document or paragraph is currently open.
WordDocumentWriterXmlWriterExceptionThrown if the XmlWriter used to write content to the stream throws an exception.
Remarks

This overload makes it possible for the developer to display text with mixed font attributes in the hyperlink. Each text fragment with different font attributes must be manifested as a separate text run. Each one is added to the textRuns list prior to calling the method.

Before the AddHyperlink method can be called, the developer must begin a paragraph via the StartParagraph method, or an exception is thrown.

In the case where the address begins with "www.", the prefix "http://" will be prepended to avoid creating a malformed URI.

Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also